package com.js.mytransitiondemo;

import androidx.appcompat.app.AppCompatActivity;

import android.app.ActivityOptions;
import android.content.Intent;
import android.os.Bundle;
import android.view.View;

import com.js.mytransitiondemo.after.AfterActivity;
import com.js.mytransitiondemo.after.AfterTwoActivity;
import com.js.mytransitiondemo.before.BeforeActivity;
import com.js.mytransitiondemo.customize.CarActivity;
import com.js.mytransitiondemo.databinding.ActivityMainBinding;
import com.js.mytransitiondemo.shareElement.ShareElementActivity;

public class MainActivity extends AppCompatActivity {

    private ActivityMainBinding binding;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        binding = ActivityMainBinding.inflate(getLayoutInflater());
        setContentView(binding.getRoot());
        initView();
    }

    private void initView() {
        binding.before.setOnClickListener(v -> {
            startActivity(new Intent(this, BeforeActivity.class));
        });
        binding.slide.setOnClickListener(v -> {
            Intent intent = new Intent(this, AfterActivity.class);
            intent.putExtra("type", 1);
            // 使用转场动画效果
            startActivity(intent, ActivityOptions.makeSceneTransitionAnimation(this).toBundle());
        });
        binding.explode.setOnClickListener(v -> {
            Intent intent = new Intent(this, AfterActivity.class);
            intent.putExtra("type", 2);
            // 使用转场动画效果
            startActivity(intent, ActivityOptions.makeSceneTransitionAnimation(this).toBundle());
        });
        binding.fade.setOnClickListener(v -> {
            Intent intent = new Intent(this, AfterActivity.class);
            intent.putExtra("type", 3);
            // 使用转场动画效果
            startActivity(intent, ActivityOptions.makeSceneTransitionAnimation(this).toBundle());
        });
        binding.shareElement.setOnClickListener(v -> {
            startActivity(new Intent(this, ShareElementActivity.class));
        });
        binding.customizeTransition.setOnClickListener(v -> {
            startActivity(new Intent(this, CarActivity.class));
        });
    }
}